import tinymce from 'tinymce/tinymce'
import { emit } from '@/utils/helpers'
import { save } from '@/api'
import { getStrData2Save } from '@/utils/save'

tinymce.PluginManager.add('docCompare', function (editor) {
  return (
    editor.ui.registry.addMenuItem('docCompare', {
      text: '对比',
      async onAction() {
        await save(getStrData2Save())
        emit('show-compare-dialog')
      }
    }),
    {
      getMetadata: function () {
        return {
          name: '对比',
          url: 'http://sfrj.cn'
        }
      }
    }
  )
})
